package com.example.lanouhn.bantangapp.activities.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.lanouhn.bantangapp.R;
import com.example.lanouhn.bantangapp.activities.utils.SPUtils;

import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.onekeyshare.OnekeyShare;

/**
 * 我的  界面的  设置界面
 * Created by lanouhn on 16/7/23.
 */
public class AvatarSetupActivity extends Activity {
    private ImageView back;//返回按键
    private LinearLayout ll_yi_jian_fan_kui; //意见反馈

    private  LinearLayout ll_share;//分享应用
    private LinearLayout lly_share; //隐藏分享布局
    private TextView tv_hint;//隐藏按钮
    private LinearLayout lly_share_background;//隐藏灰色半透明背景
    private LinearLayout ll_Interest;//编辑兴趣
    private TextView     loginout;//退出登录
    private TextView  test;//版本检测

    private LinearLayout ll_share;//分享应用
   private LinearLayout ll_Interest;//编辑兴趣
    private TextView loginout;//退出登录


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initview();
        initLinstener();

        //分享
        ShareSDK.initSDK(this, "sharesdk的appkey");

    }


    //找到控件
    private void initview() {
        setContentView(R.layout.avatar_setup_activity);
        back = (ImageView) findViewById(R.id.back);
        ll_share = (LinearLayout) findViewById(R.id.ll_share);
        ll_yi_jian_fan_kui = (LinearLayout) findViewById(R.id.ll_yi_jian_fan_kui);

        lly_share = (LinearLayout) findViewById(R.id.lly_share);
        tv_hint = (TextView) findViewById(R.id.tv_hint);
        lly_share_background = (LinearLayout) findViewById(R.id.lly_share_background);
        ll_Interest = (LinearLayout) findViewById(R.id.ll_Interest);
        loginout= (TextView) findViewById(R.id.loginout);
        test= (TextView) findViewById(R.id.test);

       ll_Interest = (LinearLayout) findViewById(R.id.ll_Interest);
        loginout = (TextView) findViewById(R.id.loginout);

    }

    //监听事件
    private void initLinstener() {
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        //意见反馈
        ll_yi_jian_fan_kui.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent it = new Intent(AvatarSetupActivity.this, Avatar_SetUp_Feedback_Activity.class);
                startActivity(it);
            }
        });
        //分享应用
        ll_share.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showShare();


            }
        });

        //编辑兴趣
        ll_Interest.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent(AvatarSetupActivity.this, Avatar_SetUp_Interest_Activity.class);
                startActivity(it);
            }
        });
        //退出登录
        loginout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SPUtils.remove(AvatarSetupActivity.this, "login");


                Intent it = new Intent(AvatarSetupActivity.this, MainActivity.class);
                startActivity(it);
            }
        });
        //版本检测
        test.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(AvatarSetupActivity.this,R.string.xin, Toast.LENGTH_SHORT).show();
            }
        });

    }

    private void showShare() {
        ShareSDK.initSDK(this);
        OnekeyShare oks = new OnekeyShare();
        //关闭sso授权
        oks.disableSSOWhenAuthorize();

        // title标题，印象笔记、邮箱、信息、微信、人人网和QQ空间等使用
        oks.setTitle("标题");
        // titleUrl是标题的网络链接，QQ和QQ空间等使用
        oks.setTitleUrl("http://sharesdk.cn");
        // text是分享文本，所有平台都需要这个字段
        oks.setText("我是分享文本");
        // imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
        //oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片
        // url仅在微信（包括好友和朋友圈）中使用
        oks.setUrl("http://sharesdk.cn");
        // comment是我对这条分享的评论，仅在人人网和QQ空间使用
        oks.setComment("我是测试评论文本");
        // site是分享此内容的网站名称，仅在QQ空间使用
        oks.setSite(getString(R.string.app_name));
        // siteUrl是分享此内容的网站地址，仅在QQ空间使用
        oks.setSiteUrl("http://sharesdk.cn");

        // 启动分享GUI
        oks.show(this);
    }

}
